import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;


public class TeamTest {
	Team myTeam;

	@Before
	public void setUp() throws Exception {
		myTeam = new Team("Canucks");
	}

	@Test
	public void constructor() {
		String name = myTeam.getTeamName();
		assertTrue(name.equals("Canucks"));
		
		int size = myTeam.size();
		assertTrue(size == 0);		
	}
	
	@Test
	public void addSinglePlayer() {
		HockeyPlayer fred = new HockeyPlayer("Fred", "Flintstone");
		
		myTeam.add(fred);
		
		int size = myTeam.size();
		assertTrue(size == 1);	
		
		HockeyPlayer who = myTeam.get(0);
		assertTrue(who == fred);
	}
	
	@Test
	public void addTwoPlayers() {
		HockeyPlayer fred = new HockeyPlayer("Fred", "Flintstone");
		HockeyPlayer sam = new HockeyPlayer("Sam", "Spaniel");
		
		myTeam.add(fred);
		myTeam.add(sam);
		
		int size = myTeam.size();
		assertTrue(size == 2);	
		
		HockeyPlayer who = myTeam.get(0);
		assertTrue(who == fred);
		
		who = myTeam.get(1);
		assertTrue(who == sam);
	}
	
	@Test
	public void addGoal() {
		HockeyPlayer fred = new HockeyPlayer("Fred", "Flintstone");
		HockeyPlayer sam = new HockeyPlayer("Sam", "Spaniel");
		
		myTeam.add(fred);
		myTeam.add(sam);
		
		myTeam.addGoal(new HockeyPlayer("Sam", "Spaniel"));
		
		int samGoals = sam.getGoals();
		assertTrue(samGoals == 1);
	}
	
	@Test
	public void totalPointsForOne() {
		addGoal();
		assertTrue(myTeam.getTotalPoints() == 1);
	}
	
	@Test
	public void totalPointsForTwo() {
		addGoal();
		assertTrue(myTeam.getTotalPoints() == 1);
		
		myTeam.addGoal(new HockeyPlayer("Fred", "Flintstone"));
		
		assertTrue(myTeam.getTotalPoints() == 2);


	}

}
